package simple.cat.util;

/**
 * @author zheng9feng
 * @Description 用于封装状态行和响应头
 * @Date 2020/12/25 00:14
 */
public class HttpProtocolUtil {
	
	public static String getHttpHeader4Success(long contentLength) {
		return "HTTP/1.1 200 OK \n"
				+ "Content-Type: text/html;charset=utf-8 \n"
				+ "content-length: " + contentLength + " \n"
				+ "\r\n";
	}
	
	public static String getHttpHeader4NotFound() {
		String commonMsg = "<h1>404 not found</h1>";
		return "HTTP/1.1 404 NotFound \n"
				+ "content-length: " + commonMsg.getBytes().length + " \n"
				+ "\r\n"
				+ commonMsg;
	}
}
